// frontend/src/router/index.js
import { createRouter, createWebHistory } from 'vue-router'
import DashboardPage from '@/views/DashboardPage.vue'
import RequirementsPage from '@/views/RequirementsPage.vue'
import TestCasesPage from '@/views/TestCasesPage.vue'

const routes = [
  {
    path: '/',
    name: 'Dashboard',
    component: DashboardPage,
    meta: { title: '仪表盘 - AI智能测试平台' }
  },
  {
    path: '/requirements',
    name: 'Requirements',
    component: RequirementsPage,
    meta: { title: '需求优化 - AI智能测试平台' }
  },
  {
    path: '/test-cases',
    name: 'TestCases',
    component: TestCasesPage,
    meta: { title: '用例生成 - AI智能测试平台' }
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/'
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

// 设置页面标题
router.beforeEach((to, from, next) => {
  document.title = to.meta.title || 'AI智能测试平台'
  next()
})

export default router